<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>

<script type="text/javascript">
<!--
$(document).ready(function() {

	$("[id^='radioPayment-']").click(function() {
		var paymentPk = this.id.substring(13);
		$('#hidden\\.paymentPk2').val(paymentPk);
		
	});
	
	$("[id^='viewPaymentImg-']").click(function() {
		var paymentPk = this.id.substring(15);
		doQueryPaymentsAction(paymentPk);
		
	});
	
	$("#doWebAtmActionBtn").click(function() {
		if (checkPaymentRadio() == false)
			return false;
		var paymentPk = $("#hidden\\.paymentPk2").val();
		doWebAtmAction(paymentPk);
		
	});
	
});

	function checkPaymentRadio()
	{
		var paymentPk = $('#hidden\\.paymentPk2').val();
		if(paymentPk == '')
		{
			alert('請選擇下載繳費單!!');
			return false;
		}
	}
//-->
</script>
	
<c:choose>
	<c:when test="${null != actionBean.queryResult && not empty actionBean.queryResult.paginatedList}">
		<stripes:form id="queryPaymentFrom" beanclass="com.feib.soeasy.action.Soez1002ActionBean" 
			method="post">
		<table id="listTable">
			<thead>
				<tr>
					<th></th>
					<th>繳費期限</th>
					<th>帳單名稱</th>
					<th>繳費帳號</th>
					<th>繳費金額</th>
					<th>繳費狀態</th>
					<th>繳費明細</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${actionBean.queryResult.paginatedList}" var="viewObj" varStatus="rowstat">
				<tr>
					<td>
						<input type="radio" id="radioPayment-<c:out value='${viewObj.paymentPk}'/>" name="radioPayment">
					</td>
					<td align="center"><fmt:formatDate value="${viewObj.payDue}" pattern="yyyy/MM/dd" /></td>
					<td><c:out value="${viewObj.paymentName}"/></td>
					<td><c:out value="${viewObj.virtualAccount}"/></td>
					<td align="right"><fmt:formatNumber value="${viewObj.totalAmount}" pattern="##,###" /></td>
					<td>待繳費</td>
					<td>
						<div id="viewPaymentImg-<c:out value='${viewObj.paymentPk}'/>"><a href="javascript: void(0)" class="btnZoom">查詢</a></div>
						
					</td>			
				</tr>
				</c:forEach>
				<tr>
					<td colspan="7" align="center">
						<stripes:submit id="doDownloadPaymentAction" name="doDownloadPaymentAction"  
							value="下載繳費單"
							onclick="return checkPaymentRadio();"/>
						<input type="button" id="doWebAtmActionBtn" value="線上繳款">
						<stripes:hidden id="hidden.paymentPk2" name="paymentPk"/>
					</td>
				</tr>
			</tbody>
			</table>
		</stripes:form>
		
	</c:when>
	<c:otherwise>
		<div id="queryNothingBlockDiv" style="display: none;">
			查無資料
		</div>			
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog({  title:'一般帳單繳費查詢' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  });
		});
		//-->
		</script>
	</c:otherwise>
</c:choose>
